home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-23 | 4.3 KB | 152 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LAboutBox.cp © 1995, Éric Forget. All rights reserved.
- // ===========================================================================
- //
- // ************************************************************************
- // * *
- // * Before using this code you should read the "License Agreement" *
- // * document and agree with it. *
- // * *
- // ************************************************************************
- //
- // LAboutBox is a wrapper class to make life easier when implementing an
- // about box.
- //
- // ---------------------------------------------------------------------------
- //
- // Instruction Notes:
- // -----------------
- //
- // 1) Write a PPob resource with Constructor (or whatever you want!);
- //
- // 2) Write a RidL resource (even an empty one!) with the same ID as your PPob;
- //
- // 3) Call LAboutBox::DoAboutBox(), a static method.
- //
- // ---------------------------------------------------------------------------
-
- #include "LAboutBox.h"
-
- #include <UModalDialogs.h>
-
-
-
- // ---------------------------------------------------------------------------
- // • DoAboutBox
- // ---------------------------------------------------------------------------
-
- void
- LAboutBox::DoAboutBox(
- ResIDT inResID)
- {
- StDialogHandler theHandler(inResID, LCommander::GetTopCommander());
- LDialogBox *theDialog = (LDialogBox *)theHandler.GetDialog();
- MessageT hitMessage = msg_Nothing;
-
-
- theDialog->Show();
-
- while (hitMessage == msg_Nothing) { // Let DialogHandler process events
-
- hitMessage = theHandler.DoDialog();
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • CreateAboutBoxStream [static]
- // ---------------------------------------------------------------------------
- // Return a new AboutBox object initialized using data from a Stream
-
- LAboutBox*
- LAboutBox::CreateAboutBoxStream(
- LStream *inStream)
- {
- return (new LAboutBox(inStream));
- }
-
-
- // ---------------------------------------------------------------------------
- // • LAboutBox
- // ---------------------------------------------------------------------------
- // Default Constructor
-
- LAboutBox::LAboutBox()
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • LAboutBox(SWindowInfo&)
- // ---------------------------------------------------------------------------
- // Construct AboutBox from the data in a struct
-
- LAboutBox::LAboutBox(
- SWindowInfo &inWindowInfo)
- : LDialogBox(inWindowInfo)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • LAboutBox(ResIDT, Uint32, LCommander*)
- // ---------------------------------------------------------------------------
- // Construct a AboutBox from a WIND Resource with the specified attributes
- // and SuperCommander
- //
- // Side Effect: Created window becomes the current port
-
- LAboutBox::LAboutBox(
- ResIDT inWINDid,
- Uint32 inAttributes,
- LCommander *inSuper)
- : LDialogBox(inWINDid, inAttributes, inSuper)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • LAboutBox(LStream*)
- // ---------------------------------------------------------------------------
- // Construct a AboutBox from the data in a Stream
-
- LAboutBox::LAboutBox(
- LStream *inStream)
- : LDialogBox(inStream)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • HandleClick
- // ---------------------------------------------------------------------------
- // Respond to a click on a Window
- //
- // The inPart parameter is the part code returned by the Toolbox FindWindow
- // routine.
-
- void
- LAboutBox::HandleClick(
- const EventRecord &/*inMacEvent*/,
- Int16 /*inPart*/)
- {
- mSuperCommander->AllowSubRemoval(this);
- }
-
-
- // ---------------------------------------------------------------------------
- // • HandleKeyPress
- // ---------------------------------------------------------------------------
- // DialogBox handles keyboard equivalents for hitting the Default and
- // Cancel Buttons.
- //
- // Default Button: Enter, Return
- // Cancel Button: Escape, Command-Period
-
- Boolean
- LAboutBox::HandleKeyPress(
- const EventRecord &/*inKeyEvent*/)
- {
- return mSuperCommander->AllowSubRemoval(this);
- }
-